<?php
/**
 * 文章分类
 * @author 陈德本
 *
 */
class catgoryService extends commonService {

    /**
     *
     * @var catgoryDao
     */
    protected $pao;

    public function __construct() {
        parent::__construct();
        $this->pao = InitPHP::getDao("catgory");
    }
    /**
     * 获取分类数组
     */
    public function getCatTree(){
        $data = $this->pao->getAllByMutiple();
        $result=array();
        if ($data){
            foreach ($data as $k=>$v){
                $result[$v['id']]=$v['title'];
            }
        }
        return $result;
    }
    /**
     * 获取导航
     * 
     * @param string $tree
     *            是否返回Tree
     * @param int $status
     *            $status=2表示获取所有导航，$status=1表示获取未禁用导航，$status=0表示获取已禁用导航
     * @return Ambigous <multitype:, multitype:array , boolean, multitype:multitype: >
     */
    public function getCatgory($tree = TRUE, $status = 2) {
        if ($status == 2) {
            $data = $this->pao->getAllByMutiple();
        } else {
            $data = $this->pao->getAllByMutiple(array(
                'status' => $status));
        }
        if ($tree) {
            $data = list_to_tree($data, "id", "pid", "sub");
        }
        return $data;
    }
}